home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-09-19 | 3.2 KB | 172 lines | [TEXT/KAHL] |
- /*** File: "StandAloneMenu_v00.c"
- *
- * Versione 00. Del 25-09-94.
- * Scritto da Cadili Francesco.
- *
- * Gestisce i menu di "StandAlone_v00.c".
- ***********************************************/
- #include "StandAloneMenu_v00.h"
- #include <Dialogs.h>
-
- /***** Include standard *****/
- /* MacHeaders Included */
-
- #ifdef DEBUG_ANSI_STANDALONE
- #include <stdio.h>
- #endif
- #include <Types.h>
- #include <Menus.h>
- #include <ToolUtils.h>
- #include <Desk.h>
- #include <Windows.h>
-
- /***** Include locali *****/
-
- // #include "MenuCall_v03.h"
- #include "ProcessNew_v00.h"
- #ifdef CONTROLLORISORSE
- #include "ControlloRisorse.h"
- #endif
-
- /***** Define macro *****/
-
- /***** Define valori *****/
-
- #pragma segment StandAloneMenu
- #define MenuBarID 128
- #define kMenuNum 3
- enum {
- fileMenuID = 128,
- editMenuID,
- appleMenuID
- };
-
- enum { // file menu item
- newItem = 1,
- quitItem = 3
- };
-
- enum {
- aboutItem = 1
- };
-
- /***** Typedef globali *****/
-
- /***** Funzioni esterne *****/
-
- /***** Variabili esterne *****/
-
- /***** Variabili globali *****/
-
- /***** Statiche globali *****/
-
- static Handle menuBar = NULL;
- static MenuHandle menuHdl[kMenuNum]; // contiene i puntatori agli elementi del menu (sono ordinati per posizione)
-
- /***** Function prototyping *****/
-
- static void about(void);
-
- /*** "SetUpMenus()"
- *
- * Mette a posto i menu.
- * Val OUTPUT: true se tutto ok, false altrimenti.
- *
- *******************************************************/
- int SetUpMenus(void)
- {
- menuBar = GetNewMBar(MenuBarID);
- #ifdef CONTROLLORISORSE
- CaricaRisorsa('MBAR', MenuBarID);
- #endif
-
- if (menuBar != 0)
- {
- SetMenuBar(menuBar);
- DrawMenuBar();
- menuHdl[0] = GetMHandle(appleMenuID);
- menuHdl[1] = GetMHandle(131);
-
- if (menuHdl[0] != NULL)
- AddResMenu(menuHdl[0], 'DRVR');
- if (menuHdl[1] != NULL)
- AddResMenu(menuHdl[1], 'FONT');
-
- return(true);
- }
- else // errore
- {
- #ifdef DEBUG_ANSI_STANDALONE
- printf("errore nell'allocazione della barra dei menu");
- #endif
-
- return(false);
- }
- }
-
- /*** "HandleMenu(mSelect)"
- *
- * Gestisce la selezione dei menu.
- * Par INPUT: "mSelect" quello che MenuSelect() e MenuKey() ritornano
- * (la parte alta é il menu ID, la parte bassa è il menu item).
- *
- *************************************************************************************/
- int HandleMenu(long mSelect)
- {
- int menuID = HiWord(mSelect);
- int menuItem = LoWord(mSelect);
- int computeNext = true;
-
- switch(menuID)
- {
- case appleMenuID:
- if (menuHdl[0] != NULL)
- {
- if (menuItem != aboutItem)
- { // devo chiamare un desk accessory
- GrafPtr savePort;
- Str255 deskAccName;
-
- GetPort(&savePort);
- GetItem(menuHdl[0], menuItem, deskAccName);
- OpenDeskAcc(deskAccName);
- SetPort(savePort);
- }
- else
- { // ha scelto about StandAlone
- about();
- }
- }
- break;
- case fileMenuID:
- switch(menuItem)
- {
- case newItem:
- ProcessNew();
- break;
-
- case quitItem:
- computeNext = false;
- break;
- }
- break;
- }
- return(computeNext);
- }
-
- /*** CantOpen()
- *
- * Errore nell'apertura del file delle risorse
- *
- *****************************************************/
- void about(void)
- {
- short itemHit;
- DialogPtr theDialog = GetNewDialog(130, NULL, (WindowPtr)-1L);
-
- ModalDialog (NULL, &itemHit);
- DisposDialog(theDialog);
- }
- /* end CantOpen */
-
-